package com.cloudlead.fleetAction.action;
import com.cloudlead.common.lang.annotation.Label;
import com.cloudlead.common.lang.persistence.EasyuiGridData;
import com.cloudlead.common.lang.persistence.ObjectList;
import com.cloudlead.common.lang.persistence.Page;
import com.cloudlead.common.worker.action.impl.AbstractActionFactory;
import com.cloudlead.common.worker.annotation.Action;
import com.cloudlead.common.worker.annotation.Order;
import com.cloudlead.fleetAction.BusinessModules;
import com.cloudlead.fleetAction.service.BaseFleetEditSer;
import com.cloudlead.fleetService.BaseFleetEditService;
import com.cloudlead.fleetService.vo.BaseCarVo;
import com.cloudlead.fleetService.vo.BaseFleetVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * Created by Jinnoo on 2015/8/12.
 */
@Controller
public class BaseFleetEditActionFactory extends AbstractActionFactory implements BaseFleetEditService {
    public BaseFleetEditActionFactory() {
        super(BusinessModules.BaseFleetEdit);
    }

    @Autowired
    BaseFleetEditSer baseFleetEditSer;

    @Action
    @Order(1)
    @Label("创建车队")
    public void createFleet(BaseFleetVo vo) {
        baseFleetEditSer.createFleet(vo);
    }

    @Action
    @Order(2)
    @Label("编辑车队")
    public void editFleet(BaseFleetVo vo) {
        baseFleetEditSer.editFleet(vo);
    }

    @Action
    @Order(3)
    @Label("单值查询")
    public Object findOneFleet(BaseFleetVo vo) {
        return baseFleetEditSer.findOneFleet(vo);
    }

    @Action
    @Order(4)
    @Label("列表查询")
    public EasyuiGridData findAllFleet(BaseFleetVo vo,@Label("页码")int page,@Label("每页条数")int rows) {
        return  new EasyuiGridData(baseFleetEditSer.findAllFleet(vo,page,rows),"id fleetId,fleetName,address,comments,baseCompany.id");
  //      return baseFleetEditSer.findAllFleet(vo,page,size);
    }

    @Action
    @Order(5)
    @Label("删除车队")
    public void delFleet(@Label("车队ID")String id) {
        baseFleetEditSer.delFleet(id);
    }
    @Override
    @Action
    @Order(6)
    @Label("车队列表")
    public ObjectList baseFleetList(@Label("公司ID")@NotNull String companyId) {
        return new ObjectList(baseFleetEditSer.baseFleetList(companyId),"id,fleetName");
    }
}
